import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:namewava/utils/jc_image_path.dart';
import 'package:namewava/utils/jc_screenutil_info.dart';
import 'package:namewava/utils/jc_text_style.dart';

class JcPop extends StatelessWidget {
  const JcPop(
      {super.key,
      required this.btnTitles,
      this.cancelTitle = 'Cancellation',
      required this.tapEvents});
  final List btnTitles;
  final String? cancelTitle;
  final Function tapEvents;

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      child: Container(
        height: JcScreenutilInfo.screenHeight,
        color: Colors.transparent,
        child: Column(
          // crossAxisAlignment: CrossAxisAlignment.end,
          mainAxisAlignment: MainAxisAlignment.end,
          children: [
            GestureDetector(
              child: Container(
                height: 140.h + 60.h * btnTitles.length,
                decoration: const BoxDecoration(
                    image: DecorationImage(
                        image: AssetImage(JcImagePath.jcWavaPopBg),
                        fit: BoxFit.fill)),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: meun(),
                ),
              ),
              onTap: () {},
            )
          ],
        ),
      ),
      onTap: () {
        Get.back();
      },
    );
  }

  List<Widget> meun() {
    List<Widget> ww = [];
    for (var i = 0; i < btnTitles.length; i++) {
      ww.add(GestureDetector(
        child: Container(
          alignment: Alignment.center,
          child: Text(
            btnTitles[i],
            style: JcTextStyle.octoberDevanagariMediumTextStyle(
                20.sp, Colors.black),
          ),
        ),
        onTap: () {
          Get.back();
          tapEvents(i);
        },
      ));
      ww.add(SizedBox(
        height: 40.h,
      ));
    }
    // for (var element in btnTitles) {

    // }
    ww.add(GestureDetector(
      child: Container(
        alignment: Alignment.center,
        child: Text(
          cancelTitle ?? '',
          style:
              JcTextStyle.octoberDevanagariMediumTextStyle(20.sp, Colors.black),
        ),
      ),
      onTap: () {
        Get.back();
      },
    ));
    return ww;
  }
}
